void main() {
  Map<String, int> ages = {'Alice': 30, 'Bob': 25, 'Charlie': 35};
  // for 循环遍历
  for (String key in ages.keys) {
    print('Key: $key');
  }
  for (int value in ages.values) {
    print('Value: $value');
  }

  // foreach迭代
  ages.forEach((key, va) {});
  ages.forEach((String key, int va) {});

  // 更新
  ages.update("Bob", (value) => 66);
  ages.putIfAbsent("Bob1", () => 661);
  //  ages.update("Bob2",(value)=> 99); // 如果key 不存在会报错
  print(ages["Bob"]);
  print(ages["Bob1"]);
  print(ages["Bob2"]);

  ages["Bob2"] = 99;
  print(ages["Bob2"]);
}
